package cn.lg.soar.system.auth.model;

import cn.lg.soar.database.translate.TranslateByEntity;
import cn.lg.soar.system.api.enums.OrgTypeEnum;
import cn.lg.soar.system.auth.entity.Org;
import cn.lg.soar.system.auth.entity.User;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * @author luguoxiang
 * @date 2022/6/13
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
@Getter
@Setter
public class OrgSelectorDTO {

    private Long id;

    private String name;

    private OrgTypeEnum type;

    @TranslateByEntity(value = User.class, label = "nickname")
    private Long director;

    private List<String> link;

    private Integer descendantQuantity;

    public static OrgSelectorDTO from(Org org) {
        if (org == null) {
            return null;
        }
        OrgSelectorDTO dto = new OrgSelectorDTO();
        dto.id = org.getId();
        dto.name = org.getName();
        dto.type = org.getType();
        dto.director = org.getDirector();
        dto.descendantQuantity = org.getDescendantQuantity();
        return dto;
    }

}
